package com.snowm.log;

import java.net.InetAddress;
import java.net.UnknownHostException;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;

public class IPLogConverter extends ClassicConverter {

	private String ip;

	public IPLogConverter() {
		String address = System.getProperty("server.address");
		if (address == null) {
			try {
				address = InetAddress.getLocalHost().getHostAddress();
			} catch (UnknownHostException e) {
				e.printStackTrace();
			}
		}
		this.ip = address;
	}

	@Override
	public String convert(ILoggingEvent event) {
		return this.ip;
	}

}
